//
//  MainViewController.m
//  侧栏
//
//  Created by Pinken on 2018/5/31.
//  Copyright © 2018年 RX. All rights reserved.
//

#import "MainViewController.h"

#import "RightViewController.h"

#define ScreenWidth [UIScreen mainScreen].bounds.size.width
#define ScreenHeight [UIScreen mainScreen].bounds.size.height

@interface MainViewController ()

@property (nonatomic, strong)RightViewController *rightCtr;

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor purpleColor];
    
    UIButton *button = [[UIButton alloc] init];
    button.frame = CGRectMake(130, 100, 100, 56);
    [button setTitle:@"Main 控制器" forState:UIControlStateNormal];
    button.backgroundColor = [UIColor blueColor];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(clickbtn) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}

- (void)clickbtn {
    NSLog(@"点击了 Main 控制器的 Button --- ");
    
    self.rightCtr = [[RightViewController alloc] init];
    [self addChildViewController:_rightCtr];
    self.rightCtr.view.frame = self.view.frame;
//    self.rightCtr.view.frame = CGRectMake(200, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
    [self.view addSubview:self.rightCtr.view];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
